package com.menusifu.onlineorder.order.controller;

import com.menusifu.onlineorder.mongo.dao.SeatingAreasDao;
import com.menusifu.onlineorder.mongo.domain.SeatingAreas;
import com.menusifu.onlineorder.order.service.OrderBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(value="OrderBillController",description="订单管理相关信息接口")
@RestController
public class OrderBillController {

    @Autowired
    OrderBillService orderBillService;

    @Autowired
    SeatingAreasDao seatingAreasDao;

    @ApiOperation(value="保存订单接口",notes="保存订单接口", httpMethod = "GET")
    @RequestMapping("saveorder")
    public String saveOrder(String order){

        orderBillService.saveOrderBill();

        return "success";
    }


    @RequestMapping("findSeatingAreas")
    public  String findSeatingAreas(){

        List<SeatingAreas> list=seatingAreasDao.findAll();
        for (SeatingAreas seatingAreas:list){
            System.out.println(seatingAreas.getName()+"------"+seatingAreas.getCreatedOn());
        }
        return "success";
    }




    @ApiOperation(value="查询所有订单",notes="查询所有订单", httpMethod = "POST")
    @PostMapping("findAllOrder")
    public String findAllOrder(String order){

        orderBillService.findAllOrder();

        try {
            Thread.sleep(30000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "success";
    }

}
